<?php

class Talktangle_FollowController extends Core_Controller_Action_Standard
{
  public function followAction(){
    $viewer = Engine_Api::_()->user()->getViewer();
    $object_id = $this->_getParam('object_id',0);
    if(empty($object_id)){
       return $this->_forward('success', 'utility', 'core', array(
          'smoothboxClose' => true,
          'parentRefresh' => false,
          'messages' => array(Zend_Registry::get('Zend_Translate')->_('User not found.'))
        ));
    }
    
    $followTable = Engine_Api::_()->getDbtable('followers','talktangle');
    $followTable->addFollower($viewer->user_id,$object_id);
    return $this->_forward('success', 'utility', 'core', array(
          'smoothboxClose' => true,
          'parentRefresh' => true,
          'messages' => array(Zend_Registry::get('Zend_Translate')->_('Follower had been add success.'))
    ));
  }
  public function unfollowAction(){
    $viewer = Engine_Api::_()->user()->getViewer();
    $object_id = $this->_getParam('object_id',0);
    if(empty($object_id)){
       return $this->_forward('success', 'utility', 'core', array(
          'smoothboxClose' => true,
          'parentRefresh' => false,
          'messages' => array(Zend_Registry::get('Zend_Translate')->_('User not found.'))
        ));
    }
    
    $followTable = Engine_Api::_()->getDbtable('followers','talktangle');
    $followTable->unFollower($viewer->user_id,$object_id);
    return $this->_forward('success', 'utility', 'core', array(
          'smoothboxClose' => true,
          'parentRefresh' => true,
          'messages' => array(Zend_Registry::get('Zend_Translate')->_('Follower had been deleted success.'))
    ));
  }
}
